package com.news.cloud.web;

import com.news.cloud.exception.ServerTechnicalException;
import com.news.cloud.exception.UnauthorizedException;
import com.news.cloud.service.FeedService;
import com.news.cloud.web.model.FeedPageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by hiephn on 2014/08/28.
 */
@Controller
@RequestMapping("/feed")
public class FeedController {

    @Autowired
    private FeedService feedService;

    @RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public FeedPageResponse get(
            @RequestParam("page") int page) throws ServerTechnicalException, UnauthorizedException {
        FeedPageResponse feedPageResponse = feedService.get(page);
        return feedPageResponse;
    }
}
